package br.inf.solutions.apresentacoes.ssp.model.hierarchy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import br.com.vexillum.model.annotations.Validate;
import br.inf.solutions.apresentacoes.ssp.model.PostGraduation;
import br.inf.solutions.apresentacoes.ssp.model.Square;

@SuppressWarnings("serial")
@Entity
@Table(name="hierarchy_function")
public class HierarchyFunction extends HierarchyStructEntity {
	
	@Validate(notNull = true)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "model_name_id", nullable = false, updatable=true)
	private ModelName modelName;
	
	@Validate(notNull = true)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "square_required_id", nullable = false, updatable=true)
	private Square squareRequired;
	
	@Validate(notNull = true)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "post_required_id", nullable = false, updatable=true)
	private PostGraduation postRequired;
	
	@Validate(notNull = true)
	@Column(name="max_persons", nullable = false, updatable=true)
	private Integer maxPersons;

	public ModelName getModelName() {
		return modelName;
	}

	public void setModelName(ModelName modelName) {
		this.modelName = modelName;
		setName(getModelName().getName());
	}

	public Square getSquareRequired() {
		return squareRequired;
	}

	public void setSquareRequired(Square squareRequired) {
		this.squareRequired = squareRequired;
	}

	public PostGraduation getPostRequired() {
		return postRequired;
	}

	public void setPostRequired(PostGraduation postRequired) {
		this.postRequired = postRequired;
	}

	public Integer getMaxPersons() {
		return maxPersons;
	}

	public void setMaxPersons(Integer maxPersons) {
		this.maxPersons = maxPersons;
	}
	
}
